import { axios } from '../core/axios'
// ---------------------------------------  common ---------------------------------------
/**
 * 生鲜商品ids查询
 *
 * @param {*}
 */
export function getFreshGoodsByIds (ids) {
  const informationIdList =
    typeof ids === 'string'
      ? ids
      : Array.isArray(ids)
        ? ids.join(',')
        : ''
  return axios.get(`fresh/goods/joinData/list`, {
    informationIdList
  })
}

/**
 * 生鲜分类ids查询
 *
 * @param {*}
 */
export function getFreshClassifyByIds (ids) {
  const informationIdList =
    typeof ids === 'string'
      ? ids
      : Array.isArray(ids)
        ? ids.join(',')
        : ''
  return axios.get(`fresh/goods/classify/joinData/list`, {
    informationIdList
  })
}

/**
 * 维保商品ids查询
 *
 * @param {*}
 */
export function getMaintenanceGoodsByIds (ids) {
  const informationIdList =
    typeof ids === 'string'
      ? ids
      : Array.isArray(ids)
        ? ids.join(',')
        : ''
  return axios.get(`maintenance/goods/joinData/list`, {
    informationIdList
  })
}

/**
 * 维保分类ids查询
 *
 * @param {*}
 */
export function getMaintenanceClassifyByIds (ids) {
  const informationIdList =
    typeof ids === 'string'
      ? ids
      : Array.isArray(ids)
        ? ids.join(',')
        : ''
  return axios.get(`maintenance/goods/classify/joinData/list`, {
    informationIdList
  })
}

/**
 * 优惠卷ids查询
 *
 * @param {*}
 */
export function getCouponByIds (ids) {
  const informationIdList =
    typeof ids === 'string'
      ? ids
      : Array.isArray(ids)
        ? ids.join(',')
        : ''
  return axios.get(`coupon/joinData/list`, {
    informationIdList
  })
}

// ---------------------------------------  common ---------------------------------------

// ---------------------------------------  asyncCheck ---------------------------------------

/**
 * 异步校验系统配置键
 * @param {*}
 */
export function checkSystemConfigKey (key, id) {
  return axios.get(`systemConfiguration/validate/configurationKey`, {
    configurationKey: key,
    notConfigurationId: id
  })
}

/**
 * 异步校验生鲜供应商名称
 * @param {*}
 */
export function checkSupplierFreshName (name, id) {
  return axios.get(`supplier/validate/supplierName`, {
    supplierName: name,
    notSupplierId: id
  })
}

/**
 * 异步校验生鲜供应商联系电话
 * @param {*}
 */
export function checkSupplierFreshContactNumber (number, id) {
  return axios.get(`supplier/validate/supplierContactNumber`, {
    supplierContactNumber: number,
    notSupplierId: id
  })
}

/**
 * 异步校验维保供应商名称
 * @param {*}
 */
export function checkMaintenanceSupplierFreshName (name, id) {
  return axios.get(`maintenanceSupplier/validate/supplierName`, {
    supplierName: name,
    notSupplierId: id
  })
}

/**
 * 异步校验维保供应商联系电话
 * @param {*}
 */
export function checkMaintenanceSupplierFreshContactNumber (number, id) {
  return axios.get(`maintenanceSupplier/validate/supplierContactNumber`, {
    supplierContactNumber: number,
    notSupplierId: id
  })
}

/**
 * 异步校验物业名称
 * @param {*}
 */
export function checkCommunityPropertyName (name, id) {
  return axios.get(`communityProperty/validate/propertyName`, {
    propertyName: name,
    notPropertyId: id
  })
}

/**
 * 异步校验物业联系电话
 * @param {*}
 */
export function checkCommunityPropertyContactNumber (number, id) {
  return axios.get(`communityProperty/validate/propertyContactNumber`, {
    propertyContactNumber: number,
    notPropertyId: id
  })
}

/**
 * 异步校验生鲜分类名称
 * @param {*}
 */
export function checkFreshCategoryName (name, id) {
  return axios.get(`fresh/goods/classify/validate/classifyName`, {
    classifyName: name,
    notClassifyId: id
  })
}

/**
 * 异步校验生鲜商品名称
 * @param {*}
 */
export function checkFreshFoodsName (name, id) {
  return axios.get(`fresh/goods/validate/goodsName`, {
    goodsName: name,
    notGoodsId: id
  })
}

/**
 * 异步校验社区名称
 * @param {*}
 */
export function checkCommunityInfoName (name, id) {
  return axios.get('community/validate/communityName', {
    communityName: name,
    notCommunityId: id
  })
}

/**
 * 异步校验团长联系电话
 * @param {*}
 */
export function checkCommanderConcatNumber (contactNumber, id) {
  return axios.get('community/groupLeader/validate/groupLeaderContactNumber', {
    groupLeaderContactNumber: contactNumber,
    notGroupLeaderId: id
  })
}

// --------------------------------------- !asyncCheck ---------------------------------------

// ----------------------------------------------- 生鲜供应商 开始 -----------------------------------------------
// 生鲜供应商列表
export function getSupplierFreshList (params) {
  return axios.get('supplier/listInfo', params)
}

// 创建生鲜供应商
export function createSupplierFresh (data) {
  return axios.post('supplier/', data)
}

// 更新生鲜供应商
export function updateSupplierFresh (id, data) {
  return axios.put(`supplier/${id}`, data)
}

// 删除生鲜供应商
export function deleteSupplierFresh (id) {
  return axios.delete(`supplier/${id}`)
}

// 生鲜供应商列表
export function getFreshSupplierSelects () {
  return axios.get('supplier/selectList')
}
// ----------------------------------------------- 生鲜供应商 结束 -----------------------------------------------

// ----------------------------------------------- 生鲜分类 开始 -----------------------------------------------
// 生鲜分类列表
export function getFreshCategoryList (params) {
  return axios.get('fresh/goods/classify/listInfo', params)
}

// 创建生鲜分类
export function createFreshCategory (data) {
  return axios.post('fresh/goods/classify/', data)
}

// 更新生鲜分类
export function updateFreshCategory (id, data) {
  return axios.put(`fresh/goods/classify/${id}`, data)
}

// 删除生鲜分类
export function deleteFreshCategory (id) {
  return axios.delete(`fresh/goods/classify/${id}`)
}

// 生鲜分类下拉列表
export function getFreshCategorySelects () {
  return axios.get('fresh/goods/classify/selectList')
}

// 生鲜分类首页展示
export function showFreshCategoryInHome (id) {
  return axios.put(`fresh/goods/classify/${id}/showHome`)
}

// 取消生鲜分类首页展示
export function offShowFreshCategoryInHome (id) {
  return axios.put(`fresh/goods/classify/${id}/showHome/cancel`)
}
// ----------------------------------------------- 生鲜分类 结束 -----------------------------------------------

// ----------------------------------------------- 生鲜主题 开始 -----------------------------------------------
// 生鲜主题下拉列表
export function getFreshThemeSelects () {
  return axios.get('fresh/goods/theme/selectList')
}
// ----------------------------------------------- 生鲜主题 结束 -----------------------------------------------

// ----------------------------------------------- 生鲜商品 开始 -----------------------------------------------
// 生鲜商品列表
export function getFreshGoodsList (params) {
  return axios.get('fresh/goods/listInfo', params)
}

export function getFreshGoodsById (id) {
  return axios.get(`fresh/goods/${id}/editInfo`)
}

// 创建生鲜商品
export function createFreshGoods (data) {
  return axios.post('fresh/goods/', data)
}

// 更新生鲜商品
export function updateFreshGoods (id, data) {
  return axios.put(`fresh/goods/${id}`, data)
}

// 生鲜商品上线
export function onlineFreshGoods (id) {
  return axios.put(`fresh/goods/${id}/online`)
}

// 生鲜商品下线
export function offlineFreshGoods (id) {
  return axios.put(`fresh/goods/${id}/offline`)
}

// 推荐生鲜商品
export function recommendFreshGoods (id) {
  return axios.put(`fresh/goods/${id}/pick`)
}

// 取消推荐生鲜商品
export function unrecommendedFreshGoods (id) {
  return axios.put(`fresh/goods/${id}/pick/cancel`)
}

// 删除生鲜商品
export function deleteFreshGoods (id) {
  return axios.delete(`fresh/goods/${id}`)
}

// 修改生鲜商品销量
export function updateFreshGoodsVolumn (goodsId, goodsSalesVolume) {
  return axios.put(`fresh/goods/${goodsId}/goodsSalesVolume/${goodsSalesVolume}`)
}
// ----------------------------------------------- 生鲜商品 结束 -----------------------------------------------

// ----------------------------------------------- 维保供应商 开始 -----------------------------------------------
// 维保供应商列表
export function getMaintenanceSupplierFreshList (params) {
  return axios.get('maintenanceSupplier/listInfo', params)
}

// 创建维保供应商
export function createMaintenanceSupplierFresh (data) {
  return axios.post('maintenanceSupplier/', data)
}

// 更新维保供应商
export function updateMaintenanceSupplierFresh (id, data) {
  return axios.put(`maintenanceSupplier/${id}`, data)
}

// 删除维保供应商
export function deleteMaintenanceSupplierFresh (id) {
  return axios.delete(`maintenanceSupplier/${id}`)
}

// 维保供应商列表
export function getMaintenanceSupplierSelects () {
  return axios.get('maintenanceSupplier/selectList')
}
// ----------------------------------------------- 维保供应商 结束 -----------------------------------------------

// ----------------------------------------------- 维保商品 开始 -----------------------------------------------
// 维保商品列表
export function getMaintenanceGoodsList (params) {
  return axios.get('maintenance/goods/listInfo', params)
}

export function getMaintenanceGoodsById (id) {
  return axios.get(`maintenance/goods/${id}/editInfo`)
}

// 创建维保商品
export function createMaintenanceGoods (data) {
  return axios.post('maintenance/goods/', data)
}

// 更新维保商品
export function updateMaintenanceGoods (id, data) {
  return axios.put(`maintenance/goods/${id}`, data)
}

// 维保商品上线
export function onlineMaintenanceGoods (id) {
  return axios.put(`maintenance/goods/${id}/online`)
}

// 维保商品下线
export function offlineMaintenanceGoods (id) {
  return axios.put(`maintenance/goods/${id}/offline`)
}

// 推荐维保商品
export function recommendMaintenanceGoods (id) {
  return axios.put(`maintenance/goods/${id}/pick`)
}

// 取消推荐维保商品
export function unrecommendedMaintenanceGoods (id) {
  return axios.put(`maintenance/goods/${id}/pick/cancel`)
}

// 删除维保商品
export function deleteMaintenanceGoods (id) {
  return axios.delete(`maintenance/goods/${id}`)
}

// 修改维保商品销量
export function updateMaintenanceVolumn (goodsId, goodsSalesVolume) {
  return axios.put(`maintenance/goods/${goodsId}/goodsSalesVolume/${goodsSalesVolume}`)
}

// ----------------------------------------------- 维保商品 结束 -----------------------------------------------

// ----------------------------------------------- 维保分类 开始 -----------------------------------------------
// 维保分类列表
export function getMaintenanceCategoryList (params) {
  return axios.get('maintenance/goods/classify/listInfo', params)
}

// 创建维保分类
export function createMaintenanceCategory (data) {
  return axios.post('maintenance/goods/classify/', data)
}

// 更新维保分类
export function updateMaintenanceCategory (id, data) {
  return axios.put(`maintenance/goods/classify/${id}`, data)
}

// 删除维保分类
export function deleteMaintenanceCategory (id) {
  return axios.delete(`maintenance/goods/classify/${id}`)
}

// 维保分类下拉列表
export function getMaintenanceCategorySelects () {
  return axios.get('maintenance/goods/classify/selectList')
}

// 维保分类首页展示
export function showMaintenanceCategoryInHome (id) {
  return axios.put(`maintenance/goods/classify/${id}/showHome`)
}

// 取消维保分类首页展示
export function offShowMaintenanceCategoryInHome (id) {
  return axios.put(`maintenance/goods/classify/${id}/showHome/cancel`)
}
// ----------------------------------------------- 维保分类 结束 -----------------------------------------------

// ----------------------------------------------- 物业 开始 -----------------------------------------------
// 物业列表
export function getCommunityPropertyList (params) {
  return axios.get('communityProperty/listInfo', params)
}

// 创建物业
export function createCommunityProperty (data) {
  return axios.post('communityProperty/', data)
}

// 更新物业
export function updateCommunityProperty (id, data) {
  return axios.put(`communityProperty/${id}`, data)
}

// 删除物业
export function deleteCommunityProperty (id) {
  return axios.delete(`communityProperty/${id}`)
}
// ----------------------------------------------- 物业 结束 -----------------------------------------------

// ----------------------------------------------- 社区信息 开始 -----------------------------------------------
// 社区信息列表
export function getCommunityInfoList (params) {
  return axios.get('community/listInfo', params)
}

// 创建社区信息
export function createCommunityInfo (data) {
  return axios.post('community', data)
}

// 更新社区信息
export function updateCommunityInfo (id, data) {
  return axios.put(`community/${id}`, data)
}

// 删除社区信息
export function deleteCommunityInfo (id) {
  return axios.delete(`community/${id}`)
}

// 社区信息下拉列表
export function getCommunitySelects () {
  return axios.get('community/selectList')
}
// ----------------------------------------------- 社区信息 结束 -----------------------------------------------

// ----------------------------------------------- 团长信息 开始 -----------------------------------------------
// 团长信息列表
export function getCommanderList (params) {
  return axios.get('community/groupLeader/listInfo', params)
}

// 创建团长信息
export function createCommander (data) {
  return axios.post('community/groupLeader', data)
}

// 更新团长信息
export function updateCommander (id, data) {
  return axios.put(`community/groupLeader/${id}`, data)
}

// 删除团长信息
export function deleteCommander (id) {
  return axios.delete(`community/groupLeader/${id}`)
}

// 团长下拉列表
export function getCommanderSelects () {
  return axios.get('/community/groupLeader/selectList')
}

// 团长结算信息
export function getCommanderClearingInfo (groupLeaderId) {
  return axios.get(`community/groupLeader/${groupLeaderId}/settlement`)
}

// 团长结算
export function doCommanderClearing (groupLeaderId, data) {
  return axios.put(`community/groupLeader/${groupLeaderId}/settlement`, data)
}
// ----------------------------------------------- 团长信息 结束 -----------------------------------------------

// ----------------------------------------------- banner 开始 -----------------------------------------------
// banner图列表
export function getBannerList (params) {
  return axios.get('banner/listInfo', params)
}

// 创建banner图
export function createBanner (data) {
  return axios.post('banner/', data)
}

// 更新banner图
export function updateBanner (bannerId, data) {
  return axios.put(`banner/${bannerId}`, data)
}

// 删除banner图
export function deleteBanner (bannerId) {
  return axios.delete(`banner/${bannerId}`)
}

// 上线banner图
export function onlineBanner (bannerId) {
  return axios.put(`banner/${bannerId}/online`)
}

// 下线banner图
export function offlineBanner (bannerId) {
  return axios.put(`banner/${bannerId}/offline`)
}

// banner类型/位置
export function getBannerTypeList () {
  return axios.get('banner/selectList/bannerType')
}

// 查询banner详情
export function getBannerById (bannerId) {
  return axios.get(`banner/${bannerId}/editInfo`)
}

// ----------------------------------------------- banner 结束 -----------------------------------------------

// ----------------------------------------------- 角色 开始 -----------------------------------------------
// 角色列表
export function getRoleList (params) {
  return axios.get('/role/listInfo', params)
}

// 创建角色
export function createRole (data) {
  return axios.post('/role/', data)
}

// 更新角色
export function updateRole (id, data) {
  return axios.put(`/role/${id}`, data)
}

// 删除角色
export function deleteRole (id) {
  return axios.delete(`/role/${id}`)
}

// 角色类型
export function getRoleTypeList () {
  return axios.get(`role/selectList/roleType`)
}

// 查找角色
export function getRoleById (id) {
  return axios.get(`/role/${id}/editInfo`)
}

// 启用角色
export function enableRole (id) {
  return axios.put(`role/${id}/enable`)
}

// 禁用角色
export function disableRole (id) {
  return axios.put(`role/${id}/disable`)
}

// 设置默认角色
export function setRoleDefault (id) {
  return axios.put(`role/${id}/default`)
}

// 角色列表
export function getRoleSelectsForCreation () {
  return axios.get('role/selectList/authorize')
}
// 角色列表/账号编辑
export function getRoleSelectsForUpdate (roleType) {
  return axios.get(`role/selectList/${roleType}/authorize`)
}
// ----------------------------------------------- 角色 结束 -----------------------------------------------

// ----------------------------------------------- 账户 开始 -----------------------------------------------
// 账户列表
export function getAccountList (params) {
  return axios.get('/account/listInfo', params)
}

// 创建账户
export function createAccount (data) {
  return axios.post('/account/', data)
}

// 更新账户
export function updateAccount (id, data) {
  return axios.put(`/account/${id}`, data)
}

// 查找账户
export function getAccountById (id) {
  return axios.get(`/account/${id}/editInfo`)
}

// 删除账户
export function deleteAccount (id) {
  return axios.delete(`/account/${id}`)
}

// 启用账户
export function enableAccount (id) {
  return axios.put(`/account/${id}/enable`)
}

// 禁用账户
export function disableAccount (id) {
  return axios.put(`/account/${id}/disable`)
}

// 重置账号密码
export function resetAccountPassword (id) {
  return axios.put(`/account/${id}/resetPassword`)
}

// 账户类型
export function getAccountTypeList () {
  return axios.get(`account/selectList/accountType`)
}

// ----------------------------------------------- 账户 结束 -----------------------------------------------

// ----------------------------------------------- 权限 开始 -----------------------------------------------
// 用户登录
export function login (data) {
  return axios.post('login', data, false)
}

// 用户退出
export function logout (data) {
  return Promise.resolve({
    result: 0
  })
}

// 权限树
export function getAuthorityTree (params) {
  return axios.get('function/treeList/select/authorize', params)
}

// 查询用户权限列表
export function getUserPermissions (params) {
  return axios.get('personal/permissions', params)
}

// 查询用户信息
export function getUserInfo () {
  return axios.get('personal')
}

// ----------------------------------------------- 权限 结束 -----------------------------------------------

// ----------------------------------------------- 订单相关 开始 -----------------------------------------------
// 维保供应商维保订单
// 维保供应商维保订单列表
export function getMaintenanceSupplierOrderList (params) {
  return axios.get('/order/maintenance/supplier/listInfo', params)
}

// 维保运营者订单
export function getMaintenanceManageOrderList (params) {
  return axios.get('/order/maintenance/manage/listInfo', params)
}

// 生鲜运营者订单
export function getFreshManageOrderList (params) {
  return axios.get('/order/fresh/manage/listInfo', params)
}

// 生鲜供应商订单
export function getFreshSupplierOrderList (params) {
  return axios.get('order/fresh/supplier/listInfo/goods', params)
}
// 接单信息
export function getTakingOrderInfo (orderId) {
  return axios.get(`/order/maintenance/${orderId}/receivingOrder`)
}
// 接单
export function takeOrder (orderId, appointmentTime) {
  return axios.put(`/order/maintenance/${orderId}/receivingOrder`, {
    appointmentTime
  })
}

// 完成订单
export function completeOrder (orderId, data) {
  return axios.put(`/order/maintenance/${orderId}/complete`, data)
}

// 用户接单列表
export function getOrderList () {
  return axios.get('/order/maintenance/supplier/receivingOrder/list')
}

// 订单完成图片列表
export function getCompletedOrderImages (orderId) {
  return axios.get(`order/maintenance/${orderId}/completePicture`)
}
// 订单完成图片列表
export function updateCompletedOrderImages (orderId, data) {
  return axios.put(`order/maintenance/${orderId}/completePicture`, data)
}

// 生鲜供应商团长订单
export function getFreshSupplierSalesCList (params) {
  return axios.get('order/fresh/supplier/listInfo/goods/groupLeader/count', params)
}

// 生鲜供应商订单
export function getFreshSupplierSalesList (params) {
  return axios.get('order/fresh/supplier/listInfo/goods/count', params)
}

// 生鲜运营者团长订单
export function getFreshManageSalesCList (params) {
  return axios.get('order/fresh/manage/listInfo/goods/groupLeader/count', params)
}

// 生鲜运营者订单
export function getFreshManageSalesList (params) {
  return axios.get('order/fresh/manage/listInfo/goods/count', params)
}

// ----------------------------------------------- 订单相关 结束 -----------------------------------------------

// ----------------------------------------------- 反馈信息 开始 -----------------------------------------------
export function getUserFeedbackList (params) {
  return axios.get('user/feedback/listInfo', params)
}

// ----------------------------------------------- 反馈信息 结束 -----------------------------------------------

// ----------------------------------------------- 系统配置 开始 -----------------------------------------------

// 系统配置列表
export function getSystemConfigList (params) {
  return axios.get('/systemConfiguration/list', params)
}
// 系统配置下拉框
export function getSystemConfigSelects () {
  return axios.get('/systemConfiguration/item/selectList')
}

// 创建系统配置
export function createSystemConfig (data) {
  return axios.post('/systemConfiguration', data)
}

// 更新系统配置
export function updateSystemConfig (id, data) {
  return axios.put(`/systemConfiguration/${id}`, data)
}

// 查找系统配置
export function getSystemConfigById (id) {
  return axios.get(`/systemConfiguration/${id}/editInfo`)
}

// 删除系统配置
export function deleteSystemConfig (id) {
  return axios.delete(`/systemConfiguration/${id}`)
}

// ----------------------------------------------- 系统配置 结束 -----------------------------------------------

// ----------------------------------------------- 导出     开始 -----------------------------------------------
// 维保供应商维保订单导出
export function exportMaintenanceSupplierOrder (params) {
  return axios.get('/order/maintenance/supplier/listInfo/down', params)
}
// ----------------------------------------------- 导出     结束 -----------------------------------------------

// ----------------------------------------------- 活动     开始 -----------------------------------------------

// 充值活动列表
export function getRechargeList (params) {
  return axios.get('/user/account/recharge/discountActivity/listInfo', params)
}
// 充值活动上线
export function onlineRecharge (rechargeActivityId) {
  return axios.put(`user/account/recharge/discountActivity/${rechargeActivityId}/online`)
}
// 充值活动下线
export function offlineRecharge (rechargeActivityId) {
  return axios.put(`user/account/recharge/discountActivity/${rechargeActivityId}/offline`)
}

// 创建充值活动
export function createRecharge (data) {
  return axios.post('user/account/recharge/discountActivity', data)
}

// 更新充值活动
export function updateRecharge (id, data) {
  return axios.put(`user/account/recharge/discountActivity/${id}`, data)
}

// 查找充值活动
export function getRechargeById (id) {
  return axios.get(`user/account/recharge/discountActivity/${id}/editInfo`)
}

// 删除充值活动
export function deleteRecharge (id) {
  return axios.delete(`user/account/recharge/discountActivity/${id}`)
}

// ----------------------------------------------- 活动     结束 -----------------------------------------------

// ----------------------------------------------- 优惠卷   开始 -----------------------------------------------

// 优惠卷列表
export function getDiscountCouponList (params) {
  return axios.get('coupon/listInfo', params)
}

// 创建优惠卷
export function createDiscountCoupon (data) {
  return axios.post('coupon', data)
}

// 更新优惠卷
export function updateDiscountCoupon (id, data) {
  return axios.put(`coupon/${id}`, data)
}

// 查找优惠卷
export function getDiscountCouponById (id) {
  return axios.get(`coupon/${id}/editInfo`)
}

// 删除优惠卷
export function deleteDiscountCoupon (id) {
  return axios.delete(`coupon/${id}`)
}

// 优惠卷上线
export function onlineDiscountCoupon (id) {
  return axios.put(`coupon/${id}/online`)
}

// 优惠卷下线
export function offlineDiscountCoupon (id) {
  return axios.put(`coupon/${id}/offline`)
}
// ----------------------------------------------- 优惠卷   结束 -----------------------------------------------
